package csc.daonjpa.java.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Transactions (sourceAccount, targetAccount, targetBank, targetBranch, Amount,
 * Date)
 */

@Entity
public class TransferTransaction implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	@Column(name = "amount")
	private long amount;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date")
	private Date date;

	@ManyToOne
	@JoinColumn(name = "srcAccountNum")
	private Account srcAcc;

	@ManyToOne
	@JoinColumn(name = "tarAccountNum")
	private TargetAccount tarAcc;

	public Account getSrcAcc() {
		return srcAcc;
	}

	public void setSrcAcc(Account srcAcc) {
		this.srcAcc = srcAcc;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public long getAmount() {
		return amount;
	}

	public void setAmount(long amount) {
		this.amount = amount;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public TargetAccount getTarAcc() {
		return tarAcc;
	}

	public void setTarAcc(TargetAccount tarAcc) {
		this.tarAcc = tarAcc;
	}
	
	/**
	 * 0-arg Constructors
	 */
	public TransferTransaction() {
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * every-fields-args Constructors
	 */
	public TransferTransaction(Account srcAcc, TargetAccount tarAcc, long amount, Date date) {
		this.srcAcc = srcAcc;
		this.tarAcc = tarAcc;
		this.amount = amount;
		this.date = date;
	}
}
